<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - self_test2.info - user/unix/userinfo.c</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">user/unix</a> - userinfo.c<span style="font-size: 80%;"> (source / <a href="userinfo.c.func.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">self_test2.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">19</td>
            <td class="headerCovTableEntry">29</td>
            <td class="headerCovTableEntryLo">65.5 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2011-07-03</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">3</td>
            <td class="headerCovTableEntry">4</td>
            <td class="headerCovTableEntryMed">75.0 %</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntry">5</td>
            <td class="headerCovTableEntry">16</td>
            <td class="headerCovTableEntryLo">31.2 %</td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">           Branch data     Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>                :            : /* Licensed to the Apache Software Foundation (ASF) under one or more</a>
<span class="lineNum">       2 </span>                :            :  * contributor license agreements.  See the NOTICE file distributed with
<span class="lineNum">       3 </span>                :            :  * this work for additional information regarding copyright ownership.
<span class="lineNum">       4 </span>                :            :  * The ASF licenses this file to You under the Apache License, Version 2.0
<span class="lineNum">       5 </span>                :            :  * (the &quot;License&quot;); you may not use this file except in compliance with
<span class="lineNum">       6 </span>                :            :  * the License.  You may obtain a copy of the License at
<span class="lineNum">       7 </span>                :            :  *
<span class="lineNum">       8 </span>                :            :  *     http://www.apache.org/licenses/LICENSE-2.0
<span class="lineNum">       9 </span>                :            :  *
<span class="lineNum">      10 </span>                :            :  * Unless required by applicable law or agreed to in writing, software
<span class="lineNum">      11 </span>                :            :  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<span class="lineNum">      12 </span>                :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<span class="lineNum">      13 </span>                :            :  * See the License for the specific language governing permissions and
<span class="lineNum">      14 </span>                :            :  * limitations under the License.
<span class="lineNum">      15 </span>                :            :  */
<span class="lineNum">      16 </span>                :            : 
<span class="lineNum">      17 </span>                :            : #include &quot;apr_strings.h&quot;
<span class="lineNum">      18 </span>                :            : #include &quot;apr_portable.h&quot;
<span class="lineNum">      19 </span>                :            : #include &quot;apr_user.h&quot;
<span class="lineNum">      20 </span>                :            : #include &quot;apr_private.h&quot;
<span class="lineNum">      21 </span>                :            : #ifdef HAVE_PWD_H
<span class="lineNum">      22 </span>                :            : #include &lt;pwd.h&gt;
<span class="lineNum">      23 </span>                :            : #endif
<span class="lineNum">      24 </span>                :            : #if APR_HAVE_SYS_TYPES_H
<span class="lineNum">      25 </span>                :            : #include &lt;sys/types.h&gt;
<span class="lineNum">      26 </span>                :            : #endif
<span class="lineNum">      27 </span>                :            : #if APR_HAVE_UNISTD_H
<span class="lineNum">      28 </span>                :            : #include &lt;unistd.h&gt; /* for _POSIX_THREAD_SAFE_FUNCTIONS */
<span class="lineNum">      29 </span>                :            : #endif
<span class="lineNum">      30 </span>                :            : #define APR_WANT_MEMFUNC
<span class="lineNum">      31 </span>                :            : #include &quot;apr_want.h&quot;
<span class="lineNum">      32 </span>                :            : 
<span class="lineNum">      33 </span>                :            : #define PWBUF_SIZE 2048
<span class="lineNum">      34 </span>                :            : 
<span class="lineNum">      35 </span>                :            : static apr_status_t getpwnam_safe(const char *username,
<span class="lineNum">      36 </span>                :            :                                   struct passwd *pw,
<span class="lineNum">      37 </span>                :            :                                   char pwbuf[PWBUF_SIZE])
<span class="lineNum">      38 </span>                :            : {
<span class="lineNum">      39 </span>                :            :     struct passwd *pwptr;
<span class="lineNum">      40 </span>                :            : #if APR_HAS_THREADS &amp;&amp; defined(_POSIX_THREAD_SAFE_FUNCTIONS) &amp;&amp; defined(HAVE_GETPWNAM_R)
<span class="lineNum">      41 </span>                :            :     apr_status_t rv;
<span class="lineNum">      42 </span>                :            : 
<span class="lineNum">      43 </span>                :            :     /* POSIX defines getpwnam_r() et al to return the error number
<span class="lineNum">      44 </span>                :            :      * rather than set errno, and requires pwptr to be set to NULL if
<span class="lineNum">      45 </span>                :            :      * the entry is not found, imply that &quot;not found&quot; is not an error
<a name="46"><span class="lineNum">      46 </span>                :            :      * condition; some implementations do return 0 with pwptr set to</a>
<span class="lineNum">      47 </span>                :            :      * NULL. */
<span class="lineNum">      48 </span>                :<span class="lineCov">          1 :     rv = getpwnam_r(username, pw, pwbuf, PWBUF_SIZE, &amp;pwptr);</span>
<span class="lineNum">      49 </span>  [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span><span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineCov">          1 :     if (rv) {</span>
<span class="lineNum">      50 </span>                :<span class="lineNoCov">          0 :         return rv;</span>
<span class="lineNum">      51 </span>                :            :     }
<span class="lineNum">      52 </span>[<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>][<span class="branchNoExec" title="Branch 2 was not executed"> # </span><span class="branchNoExec" title="Branch 3 was not executed"> # </span>]:<span class="lineCov">          1 :     if (pwptr == NULL) {</span>
<span class="lineNum">      53 </span>                :<span class="lineNoCov">          0 :         return APR_ENOENT;</span>
<span class="lineNum">      54 </span>                :            :     }
<span class="lineNum">      55 </span>                :            : #else
<span class="lineNum">      56 </span>                :            :     /* Some platforms (e.g. FreeBSD 4.x) do not set errno on NULL &quot;not
<span class="lineNum">      57 </span>                :            :      * found&quot; return values for the non-threadsafe function either. */
<span class="lineNum">      58 </span>                :            :     errno = 0;
<span class="lineNum">      59 </span>                :            :     if ((pwptr = getpwnam(username)) != NULL) {
<span class="lineNum">      60 </span>                :            :         memcpy(pw, pwptr, sizeof *pw);
<span class="lineNum">      61 </span>                :            :     }
<span class="lineNum">      62 </span>                :            :     else {
<span class="lineNum">      63 </span>                :            :         return errno ? errno : APR_ENOENT;
<span class="lineNum">      64 </span>                :            :     }
<span class="lineNum">      65 </span>                :            : #endif
<span class="lineNum">      66 </span>                :<span class="lineCov">          1 :     return APR_SUCCESS;</span>
<span class="lineNum">      67 </span>                :            : }
<span class="lineNum">      68 </span>                :            : 
<span class="lineNum">      69 </span>                :            : APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname,
<span class="lineNum">      70 </span>                :            :                                                const char *username,
<span class="lineNum">      71 </span>                :            :                                                apr_pool_t *p)
<span class="lineNum">      72 </span>                :<span class="lineNoCov">          0 : {</span>
<span class="lineNum">      73 </span>                :            :     struct passwd pw;
<span class="lineNum">      74 </span>                :            :     char pwbuf[PWBUF_SIZE];
<span class="lineNum">      75 </span>                :            :     apr_status_t rv;
<span class="lineNum">      76 </span>                :            : 
<span class="lineNum">      77 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :     if ((rv = getpwnam_safe(username, &amp;pw, pwbuf)) != APR_SUCCESS)</span>
<span class="lineNum">      78 </span>                :<span class="lineNoCov">          0 :         return rv;</span>
<span class="lineNum">      79 </span>                :            : 
<span class="lineNum">      80 </span>                :            : #ifdef OS2
<span class="lineNum">      81 </span>                :            :     /* Need to manually add user name for OS/2 */
<span class="lineNum">      82 </span>                :            :     *dirname = apr_pstrcat(p, pw.pw_dir, pw.pw_name, NULL);
<span class="lineNum">      83 </span>                :            : #else
<span class="lineNum">      84 </span>                :<span class="lineNoCov">          0 :     *dirname = apr_pstrdup(p, pw.pw_dir);</span>
<span class="lineNum">      85 </span>                :            : #endif
<span class="lineNum">      86 </span>                :<span class="lineNoCov">          0 :     return APR_SUCCESS;</span>
<span class="lineNum">      87 </span>                :            : }
<span class="lineNum">      88 </span>                :            : 
<span class="lineNum">      89 </span>                :            : 
<span class="lineNum">      90 </span>                :            : 
<span class="lineNum">      91 </span>                :            : APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid,
<a name="92"><span class="lineNum">      92 </span>                :            :                                           apr_gid_t *gid,</a>
<span class="lineNum">      93 </span>                :            :                                           apr_pool_t *p)
<span class="lineNum">      94 </span>                :<span class="lineCov">          6 : {</span>
<span class="lineNum">      95 </span>                :<span class="lineCov">          6 :     *uid = getuid();</span>
<span class="lineNum">      96 </span>                :<span class="lineCov">          6 :     *gid = getgid();</span>
<span class="lineNum">      97 </span>                :            :   
<span class="lineNum">      98 </span>                :<span class="lineCov">          6 :     return APR_SUCCESS;</span>
<span class="lineNum">      99 </span>                :            : }
<span class="lineNum">     100 </span>                :            : 
<span class="lineNum">     101 </span>                :            : 
<span class="lineNum">     102 </span>                :            : 
<span class="lineNum">     103 </span>                :            : 
<span class="lineNum">     104 </span>                :            : APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *uid, apr_gid_t *gid,
<span class="lineNum">     105 </span>                :            :                                       const char *username, apr_pool_t *p)
<span class="lineNum">     106 </span>                :<span class="lineCov">          1 : {</span>
<span class="lineNum">     107 </span>                :            :     struct passwd pw;
<span class="lineNum">     108 </span>                :            :     char pwbuf[PWBUF_SIZE];
<span class="lineNum">     109 </span>                :            :     apr_status_t rv;
<span class="lineNum">     110 </span>                :            :         
<span class="lineNum">     111 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :     if ((rv = getpwnam_safe(username, &amp;pw, pwbuf)) != APR_SUCCESS)</span>
<span class="lineNum">     112 </span>                :<span class="lineNoCov">          0 :         return rv;</span>
<span class="lineNum">     113 </span>                :            : 
<span class="lineNum">     114 </span>                :<span class="lineCov">          1 :     *uid = pw.pw_uid;</span>
<span class="lineNum">     115 </span>                :<span class="lineCov">          1 :     *gid = pw.pw_gid;</span>
<span class="lineNum">     116 </span>                :            : 
<span class="lineNum">     117 </span>                :<span class="lineCov">          1 :     return APR_SUCCESS;</span>
<span class="lineNum">     118 </span>                :            : }
<span class="lineNum">     119 </span>                :            : 
<a name="120"><span class="lineNum">     120 </span>                :            : APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid,</a>
<span class="lineNum">     121 </span>                :            :                                            apr_pool_t *p)
<span class="lineNum">     122 </span>                :<span class="lineCov">          1 : {</span>
<span class="lineNum">     123 </span>                :            :     struct passwd *pw;
<span class="lineNum">     124 </span>                :            : #if APR_HAS_THREADS &amp;&amp; defined(_POSIX_THREAD_SAFE_FUNCTIONS) &amp;&amp; defined(HAVE_GETPWUID_R)
<span class="lineNum">     125 </span>                :            :     struct passwd pwd;
<span class="lineNum">     126 </span>                :            :     char pwbuf[PWBUF_SIZE];
<span class="lineNum">     127 </span>                :            :     apr_status_t rv;
<span class="lineNum">     128 </span>                :            : 
<span class="lineNum">     129 </span>                :<span class="lineCov">          1 :     rv = getpwuid_r(userid, &amp;pwd, pwbuf, sizeof(pwbuf), &amp;pw);</span>
<span class="lineNum">     130 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :     if (rv) {</span>
<span class="lineNum">     131 </span>                :<span class="lineNoCov">          0 :         return rv;</span>
<span class="lineNum">     132 </span>                :            :     }
<span class="lineNum">     133 </span>                :            : 
<span class="lineNum">     134 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :     if (pw == NULL) {</span>
<span class="lineNum">     135 </span>                :<span class="lineNoCov">          0 :         return APR_ENOENT;</span>
<span class="lineNum">     136 </span>                :            :     }
<span class="lineNum">     137 </span>                :            : 
<span class="lineNum">     138 </span>                :            : #else
<span class="lineNum">     139 </span>                :            :     errno = 0;
<span class="lineNum">     140 </span>                :            :     if ((pw = getpwuid(userid)) == NULL) {
<span class="lineNum">     141 </span>                :            :         return errno ? errno : APR_ENOENT;
<span class="lineNum">     142 </span>                :            :     }
<span class="lineNum">     143 </span>                :            : #endif
<span class="lineNum">     144 </span>                :<span class="lineCov">          1 :     *username = apr_pstrdup(p, pw-&gt;pw_name);</span>
<span class="lineNum">     145 </span>                :<span class="lineCov">          1 :     return APR_SUCCESS;</span>
<span class="lineNum">     146 </span>                :            : }
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.9</a></td></tr>
  </table>
  <br>

</body>
</html>
